<template>
    <div>
        <table class="table table-bordered">
            <tbody>
                <tr>
                    <td>科室名称</td>
                    <td><input type="text" v-model="querInfo.hospName"></td>
                </tr>
                <tr>
                    <td>科室类别</td>
                    <td><input type="text" v-model="querInfo.hospType"></td>
                </tr>
                <tr>
                    <td>使用状态</td>
                    <td><input type="text" v-model="querInfo.hospState"></td>
                </tr>
                <tr>
                    <td>门诊诊室</td>
                    <td><input type="text" v-model="querInfo.hospRoom"></td>
                </tr>
                <tr>
                    <td>住院病区</td>
                    <td><input type="text" v-model="querInfo.hospArea"></td>
                </tr>
                <tr>
                    <td>科室简介</td>
                    <td><input type="text" v-model="querInfo.hospJj"></td>
                </tr>
                <tr>
                    <td>科室电话</td>
                    <td><input type="text" v-model="querInfo.hospTel"></td>
                </tr>
                <tr>
                    <td></td>
                    <td><input type="button" value="添加" @click="ok"></td>
                </tr>
            </tbody>
        </table>
    </div>
</template>

<script setup lang="ts">
import { ref, reactive, onMounted } from 'vue';
import axios from 'axios';
import moment from 'moment';
import { useRoute, useRouter } from 'vue-router';
const route = useRoute();
const router = useRouter();

let querInfo: any = reactive({
    "hospId": route.query.id,
    "hospName": "",
    "hospType": "",
    "hospState": "",
    "hospRoom": "",
    "hospArea": "",
    "hospJj": "",
    "hospTel": "",

})
onMounted(() => {
    fantain();
})
const fantain = () => {
    
    axios({
        url: '/api/Hosp/HospFantian',
        method: 'get',
        params: {
            id: route.query.id
        }
    })
        .then(res => {
            console.log(res);

            Object.assign(querInfo, res.data)
        })
}

const ok = () => {
    axios({
        url: '/api/Hosp/HospUpdate',
        method: 'put',
        data: querInfo
    })
        .then((res) => {
            if (res.data == -1) {
                alert("名称不能重复");
                return;
            }
            else if (res.data > 0) {
                alert("修改成功");
                return;
            }
            else {
                alert("修改失败")
                return;
            }
        })
}




</script>

<style scoped></style>